package com.myteam.fugaocrm.controller;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;

import com.myteam.fugaocrm.modle.FgRemindMessage;
import com.myteam.fugaocrm.service.RemindMessageServiceImpl;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class RemindMessageController {
	@Resource protected RemindMessageServiceImpl remindMessageServiceImpl;
	
	/**
	 * 点击提醒，查询列表
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	@RequestMapping("show/remind")
	@ResponseBody
	public List<String> showRemind(HttpServletRequest request, HttpServletResponse response) throws Exception {
		List<String> list = new ArrayList<String>();
		
		Integer staffId = Integer.parseInt(request.getParameter("staffId").toString());
		
		//查询提醒数量(当前用户的提醒数量)
		Integer remindCount = remindMessageServiceImpl.selectRemindCount(staffId);
		request.getSession().setAttribute("remindCount", remindCount);
		
		//查询提醒信息
		List<FgRemindMessage> remindList = remindMessageServiceImpl.selectRemindList(staffId);
		
		if(remindList != null && remindList.size() > 0) {
			for(FgRemindMessage remind : remindList) {
				if(remind.getTypeId() == null || remind.getTypeId() == 1 || remind.getTypeId() == 6) {
					list.add(remind.getRemindContent() + ".../project/projectBeforeFormPage?projectId=" + remind.getProjectId());
				}else {
					list.add(remind.getRemindContent() + ".../project/projectImplementFormPage?projectId=" + remind.getProjectId());
				}
			}
		}
		
		return list;
	}
}
